<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class service extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model(array('m_jenis', 'm_siswa', 'm_soal'));
    }

    function index() {
        $this->load->library('xmlrpc');
        $this->load->library('xmlrpcs');
        //select
        $config['functions']['getjenis'] = array('function' => 'service.get_jenis');
        $config['functions']['getsiswa'] = array('function' => 'service.get_siswa');
        $config['functions']['getsoal'] = array('function' => 'service.get_soal');
        $config['functions']['login'] = array('function' => 'service.login');
        $config['functions']['getjawaban'] = array('function' => 'service.get_jawaban');
        $config['functions']['getimageall'] = array('function' => 'service.get_image_all');
        $this->xmlrpcs->initialize($config);
        $this->xmlrpcs->serve();
    }

    function get_jenis($request) {
        $param = $request->output_parameters();
        $data = $this->m_jenis->ambil_jenis($param[0],NULL, NULL);
        $response = array(json_encode($data));
        return $this->xmlrpc->send_response($response);
    }

    function get_siswa() {
        $data = $this->m_siswa->ambil(NULL, NULL);
        $response = array(json_encode($data));
        return $this->xmlrpc->send_response($response);
    }

    function get_soal($request) {
        $param = $request->output_parameters();
        $data = $this->m_soal->ambil($param[0], NULL, NULL);
        $response = array(json_encode($data));
        return $this->xmlrpc->send_response($response);
    }
    
    function get_jawaban($request){
        $param = $request->output_parameters();
        $data = $this->m_soal->ambil_jawaban($param[0], NULL, NULL);
        $response = array(json_encode($data));
        return $this->xmlrpc->send_response($response);
    }

    function login($request) {
        $param = $request->output_parameters();
        $data = $this->m_siswa->login_siswa($param[0], $param[1]);
        $response = array(json_encode($data));
        return $this->xmlrpc->send_response($response);
    }
    
    function get_image_all(){
        $data = $this->m_soal->get_image();
        $response = array(json_encode($data));
        return $this->xmlrpc->send_response($response);
    }

}

?>
